package com.focusai.efairy.model.request;

import com.focusai.efairy.model.manager.CacheManager;
import com.focusai.efairy.network.Response;
import com.focusai.efairy.network.exception.ParseException;
import com.focusai.efairy.network.request.base.PureJSONRequest;
import com.focusai.efairy.network.utils.UrlUtils;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.Map;

/**
 * Created by luo_guangwen on 2017/9/18.
 */

public class AddGmToProjectReqeust extends PureJSONRequest<String> {
    private String phone;
    private String name;
    private String efairyproject_id;
    public AddGmToProjectReqeust(String projectId,String phone,String name, Response.Listener<String> listener) {
        super(UrlUtils.createUrl("/appapi/manage_project_gm"), listener);
        this.phone = phone;
        this.name = name;
        this.efairyproject_id = projectId;
    }

    @Override
    protected String parse(String result) throws ParseException {
        return result;
    }

    @Override
    public Map<String, String> getParams() throws JSONException {
        return super.getParams();
    }

    @Override
    public String getPureJSON() throws JSONException {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("efairyuser_id", CacheManager.getUserId());
        jsonObject.put("access_token", CacheManager.getAccessToken());
        jsonObject.put("efairyuser_phonenumber", phone);
        jsonObject.put("efairyuser_nickname", name);
        jsonObject.put("efairyproject_id", efairyproject_id);
        return jsonObject.toString();
    }

}

